offline plotly is here.

download for IPython notebook for $249/year
DOWNLOAD

Plotly for Python - User Guide

======= --- permalink: /python/style-template description: Markdown CSS Style Template name: Markdown CSS Style Template has_thumbnail: false thumbnail: /images/static-image language: python layout: user-guide page_type: u-guide sitemap: false --- >>>>>>> efbd4c4c8736a7101a2e98e15c50a1261beb684e:_posts/user_guide_python/2015-06-30-style-template.html

This is an H1

This is an H2

This is an H3

This is an H4

This is an H5
This is an H6

This is a block of text.

  • Here is a list
  • of items
  1. and
  2. a few
  3. numbers

this is a quote

All you need to do is pip install plotly and then import plotly.plotly as py

Emailing Plotly Graphs

In the Plotly Webapp you can share your graphs over email to your colleagues who are also Plotly members. If your making graphs periodically or automatically, e.g. in Python with a cron job, it can be helpful to also share the graphs that you're creating in an email to your team.

This notebook is a primer on sending nice HTML emails with Plotly graphs in Python. We use:

In [1]:
# This is a comment
from plotly.offline import iplot, init_notebook_mode
In [2]:
init_notebook_mode()
In [3]:
iplot([{'x': [1, 2, 3], 'y': [3, 1, 5]}])
Drawing...

Updating graphs

If we use the same filename, the graph will save to the same URL. So, if we include a graph in an email by it's URL, we can update that graph by calling py.plot with the same filename.

In [14]:
for i in range(100):
    print i
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
In [ ]:
 
<<<<<<< HEAD:_site/python/offline/index.html
In [11]:
iplot(cf.datagen.lines().iplot(asFigure=True,
                               kind='scatter',xTitle='Dates',yTitle='Returns',title='Returns'))
Drawing...
In [12]:
iplot(cf.datagen.heatmap(20,20).iplot(asFigure=True,
                                      kind='heatmap',colorscale='spectral',title='Cufflinks - Heatmap'))
Drawing...
In [12]:
import pandas as pd

df_airports = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/2011_february_us_airport_traffic.csv')
df_airports.head()

df_flight_paths = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/2011_february_aa_flight_paths.csv')
df_flight_paths.head()

airports = [ dict(
        type = 'scattergeo',
        locationmode = 'USA-states',
        lon = df_airports['long'],
        lat = df_airports['lat'],
        hoverinfo = 'text',
        text = df_airports['airport'],
        mode = 'markers',
        marker = dict( 
            size=2, 
            color='rgb(255, 0, 0)',
            line = dict(
                width=3,
                color='rgba(68, 68, 68, 0)'
            )
        ))]
        
flight_paths = []
for i in range( len( df_flight_paths ) ):
    flight_paths.append(
        dict(
            type = 'scattergeo',
            locationmode = 'USA-states',
            lon = [ df_flight_paths['start_lon'][i], df_flight_paths['end_lon'][i] ],
            lat = [ df_flight_paths['start_lat'][i], df_flight_paths['end_lat'][i] ],
            mode = 'lines',
            line = dict(
                width = 1,
                color = 'red',
            ),
            opacity = float(df_flight_paths['cnt'][i])/float(df_flight_paths['cnt'].max()),
        )
    )
    
layout = dict(
        title = 'Feb. 2011 American Airline flight paths<br>(Hover for airport names)',
        showlegend = False, 
        height = 800,
        geo = dict(
            scope='north america',
            projection=dict( type='azimuthal equal area' ),
            showland = True,
            landcolor = 'rgb(243, 243, 243)',
            countrycolor = 'rgb(204, 204, 204)',
        ),
    )
    
fig = dict( data=flight_paths + airports, layout=layout )

iplot(fig)
Drawing...
In [13]:
import plotly.plotly as py # all methods in plotly.plotly will communicate with a Plotly Cloud or Plotly Enterprise

# get_figure downloads a figure from plot.ly or Plotly Enterprise. 
# You need to provide credentials to download figures: https://plot.ly/python/getting-started/
fig = py.get_figure('https://plot.ly/~jackp/8715', raw=True)
iplot(fig)
Drawing...